[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
settextstyle() Set Current Text Font, Direction and Size
#include <graphics.h>
void far settextstyle(font,dir,charsize);
int font;
int dir;
int charsize;
settextstyle() sets the current text font, direction and character
size. All calls to outtext() and outtextxy() are affected by the new
settings.
The graphics library includes an 8x8 bit-mapped font, in which each
character is defined by a matrix of pixels, and several stroked
fonts, in which each character is defined by a series of vectors
which determine how that character is drawn.
'font' can be an 8x8 bit-mapped font or one of several "stroked"
fonts available. The different types of fonts available are defined
in the enumeration 'font_names', defined in <graphics.h> as:
Name Value Description
DEFAULT_FONT 0 8x8 bit_mapped font
TRIPLEX_FONT 1 Stroked triplex font
SMALL_FONT 2 Stroked small font
SANS_SERIF_FONT 3 Stroked sans-serif font
GOTHIC_FONT 4 Stroked gothic font
The 8x8 bit-mapped font is the default font and is always available.
The stroked fonts are kept in separate .CHR files on disk and can be
loaded at run time or converted to .OBJ files (with the BGIOBJ
utility) and linked to your .EXE files. (See registerbgifont().)
'dir' can be either horizontal text (left to right) or vertical text
(rotated 90 degrees counterclockwise). The values for 'dir' are
defined in <graphics.h> as:
Name Value Description
HORIZ_DIR 0 Left to right
VERT_DIR 1 Bottom to top
The default direction is HORIZ_DIR.
'charsize' allows each character to be magnified by a specific
factor. If 'charsize' has a value of 0, the stroked font is magnified
using the default character magnification factor of 4, or the user-
defined character size set using setusercharsize(). If 'charsize'
has a value greater than 0, the 8x8 bit-mapped or stroked font is
magnified by that factor. (For example, if 'charsize' is 1, an 8x8
bit-mapped font is displayed in an 8x8 pixel rectangle. If
'charsize' is 2, an 8x8 bit-mapped font is displayed in a 16x16 pixel
rectangle, etc.)
settextstyle() affects all subsequent calls to outtext() and
outtextxy().
Returns: Nothing. If an error occurs while the stroked fonts are
being loaded off disk, graphresult() can be coded to
return:
-8 Font file no found
-9 Not enough memory to load font
-11 Generic error
-12 Graphics I/O error
-13 Invalid font file
-14 Invalid font number
-------------------------------- Example ---------------------------------
The following statements save the original text settings, change the
settings and print an example, then restore the original settings.
#include <graphics.h>
#include <conio.h>
main()
{
int gdriver = DETECT;
int gmode;
struct textsettingstype textset;
initgraph(&gdriver,&gmode,"");
gettextsettings(&textset);
outtextxy(100,32,"Default text settings");
getch();
settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
outtextxy(100,100,"Gothic Font");
getch();
settextstyle(textset.font,textset.directions,
textset.charsize);
outtextxy(100,200,"Restore default text settings");
getch();
closegraph();
}
See Also:
settextjustify()
settextstyle()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson